package com.itlong.cloud.user.sdk;

import com.itlong.cloud.POJO.DTO.sdk.SDKAuthUserGetPageDTO;
import com.itlong.cloud.POJO.DTO.sdk.SDKSaveAppUserDTO;
import com.itlong.cloud.POJO.PO.*;
import com.itlong.cloud.POJO.VO.sdk.DeveloperAuthSafeSettingsVO;
import com.itlong.cloud.POJO.VO.sdk.SDKServerAppUserSaveVO;
import com.itlong.cloud.POJO.VO.sdk.SDKServerUserCacheVO;
import com.itlong.cloud.utils.page.Page;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

/**
 * <desc>
 * SDK用户服务暴露层接口
 * </desc>
 *
 * @createDate 2017/10/27
 */
@FeignClient(name = "user-service")
public interface ISDKServerOldUserServiceClient {

    /**
     * <desc>
     * SDK校验登录用户
     * <desc/>
     *
     * @param appid 独立开发者userId
     * @param token 登录令牌
     * @return SDKServerUserCacheVO   校验人员返回VO
     * @author Biao.R
     * @createDate 2017/10/27
     */
    @PostMapping(path = "/sdkServer/user/checkSDKCacheUser")
    SDKServerUserCacheVO checkSDKCacheUser(@RequestParam("appid") String appid, @RequestParam("token") String token);

    /**
     * <desc>
     * 查询PropertyRoleProjectPO
     * <desc/>
     *
     * @param roleProjectPO 查询条件对象
     * @return List<PropertyRoleProjectPO>  查询的对象结果集
     * @author Biao.R
     * @createDate 2017/11/3
     */
    @PostMapping(path = "/sdkServer/user/getRoleProject")
    List<PropertyRoleProjectPO> getRoleProject(@RequestBody PropertyRoleProjectPO roleProjectPO);

    /**
     * <desc>
     * SDK服务端登录
     * <desc/>
     *
     * @param appid     应用接入凭证
     * @param appsecret 应用接入密钥
     * @return 缓存对象
     * @author Biao.R
     * @createDate 2017/11/9
     */
    @PostMapping(path = "/sdkServer/user/sdkServerLogin")
    SDKServerUserCacheVO sdkServerLogin(@RequestParam("appid") String appid, @RequestParam("appsecret") String appsecret);

    /**
     * <desc>
     * 授权业主
     * <desc/>
     *
     * @param sdkSaveAppUserDTO 被授权的对象
     * @return
     * @author Biao.R
     * @createDate 2017/11/16
     */
    @PostMapping(path = "/sdkServer/user/addHouserOrFamily")
    SDKServerAppUserSaveVO addHouserOrFamily(@RequestBody SDKSaveAppUserDTO sdkSaveAppUserDTO);

    /**
     * <desc>
     * 根据参数查询用户房间关联表
     * <desc/>
     *
     * @param params 查询参数
     * @return List<AppUserRoomPO>    查询出的用户房间结果集
     * @author Biao.R
     * @createDate 2017/11/21
     */
    @PostMapping(path = "/sdkServer/user/getUserRoomByParam")
    List<AppUserRoomPO> getUserRoomByParam(@RequestBody Map<String, Object> params);

    /**
     * <desc>
     * 根据参数查询授权关系表
     * <desc/>
     *
     * @param paramMap 查询参数集
     * @return 查询到的授权关系对象集
     * @author Biao.R
     * @createDate 2017/11/21
     */
    @PostMapping(path = "/sdkServer/user/getAuthRelationsByParams")
    List<AppAuthRelationsPO> getAuthRelationsByParams(@RequestBody Map<String, Object> paramMap);

    /**
     * <desc>
     * 根据手机号查询APP用户
     * <desc/>
     *
     * @param phoneNum 待查询的手机号
     * @return 查询到的用户信息
     * @author Biao.R
     * @createDate 2017/11/22
     */
    @PostMapping(path = "/sdkServer/user/getAppUserByPhone")
    AppUserInfoPO getAppUserByPhone(@RequestParam("phoneNum") String phoneNum);

    /**
     * <desc>
     * 分页查询被授权人列表
     * <desc/>
     *
     * @param sdkAuthUserGetPageDTO 查询参数对象
     * @return 返回分页对象结果
     * @author Biao.R
     * @createDate 2017/11/22
     */
    @PostMapping(path = "/sdkServer/user/getAuthRelationsPage")
    Page<AppAuthRelationsPO> getAuthRelationsPage(@RequestBody SDKAuthUserGetPageDTO sdkAuthUserGetPageDTO);

    /**
     * <desc>
     * 根据userId查询AppUser
     * <desc/>
     *
     * @param userId 待查询的userId
     * @return 查询出的appUser对象
     * @author Biao.R
     * @createDate 2017/11/22
     */
    @PostMapping(path = "/sdkServer/user/getAppUserByUserId")
    AppUserInfoPO getAppUserByUserId(@RequestParam("userId") String userId);

    /**
     * <desc>
     * 更新授权关系表
     * <desc/>
     *
     * @param authRelationsPO 待更新对象
     * @return 更新数量
     * @author Biao.R
     * @createDate 2017/11/23
     */
    @PostMapping(path = "/sdkServer/user/updateAuthRelations")
    Integer updateAuthRelations(@RequestBody AppAuthRelationsPO authRelationsPO);

    /**
     * <desc>
     * 批量添加App用户
     * <desc/>
     *
     * @param saveAppUserDTOs 批量添加用户
     * @return 返回数量Map
     * @author Biao.R
     * @createDate 2017/11/23
     */
    @PostMapping(path = "/sdkServer/user/addAppUsers")
    Map<String, Object> addAppUsers(@RequestBody List<SDKSaveAppUserDTO> saveAppUserDTOs);

    /**
     * <desc>
     * 获取物业用户信息，条件：userId
     * </desc>
     *
     * @param appid 即userId
     * @return 物业用户信息
     * @author wangzhi
     * @createDate 2018/12/19
     */
    @PostMapping(path = "/sdkServer/user/getPropertyUserByAppId")
    PropertyUserInfoPO getPropertyUserByAppId(@RequestParam(value = "appid", required = false) String appid) throws Exception;

    /**
     * <desc>
     * 获取开发者授权安全设置信息，条件：userId
     * </desc>
     *
     * @param appid 即userId
     * @return 开发者授权安全设置VO
     * @author wangzhi
     * @createDate 2018/12/19
     */
    @PostMapping(path = "/sdkServer/user/getSafeSettings")
    DeveloperAuthSafeSettingsVO getSafeSettings(@RequestParam("appid") String appid) throws Exception;

    /**
     * <desc>
     * 获取物业用户信息，条件：username
     * </desc>
     *
     * @param appid 即userName
     * @return 物业用户信息
     * @author wangzhi
     * @createDate 2018/12/19
     */
    @PostMapping(path = "/sdkServer/user/getPropertyUserByUserName")
    PropertyUserInfoPO getPropertyUserByUserName(@RequestParam(value = "appid", required = false) String appid) throws Exception;

    /**
     * <desc>
     * 获取机器人编号
     * </desc>
     *
     * @param appid 即userName
     * @return 机器人编号
     * @author maju
     * @createDate 2021/05/26
     */
    @PostMapping(path = "/sdkServer/user/getRobotDevelopRobotInfo")
    String getRobotDevelopRobotInfo(@RequestParam(value = "appid") String appid) throws Exception;

}
